/*
 * Copyright (C) 2023, KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 */

#include "notification-window.h"
#include "notification-model.h"
#include "notification-group-model.h"

#include <QQmlEngine>
#include <QQmlContext>

using namespace UkuiNotification;

NotificationCenterWindow::NotificationCenterWindow(QWindow *parent) : QQuickView(parent)
{
    setResizeMode(QQuickView::SizeRootObjectToView);
    resize(600, 600);
    engine()->rootContext()->setContextProperty("notificationModel", NotificationModel::instance());
    engine()->rootContext()->setContextProperty("notificationWindow", this);

    NotificationGroupModel *groupModel = new NotificationGroupModel(this);
    qRegisterMetaType<NotificationGroupModel*>();
    groupModel->setSourceModel(NotificationModel::instance());
    engine()->rootContext()->setContextProperty("groupModel", groupModel);
    engine()->rootContext()->setContextProperty("sourceModel", NotificationModel::instance());

    engine()->addImportPath("qrc:/qml");

    setSource(QUrl("qrc:/qml/notificationView.qml"));
}

bool NotificationCenterWindow::event(QEvent *event)
{
    return QQuickWindow::event(event);
}
